<?php
include_once('common/header.php');			
if($AppUI->id <=0) {
	Vfriend_Function::redirect(HOST_VFRIEND);
}
$intLimit		= PRODUCT_LIMIT;
$intCate		= $objRequest->getParam('cate',null);
$intSub			= $objRequest->getParam('sub',null);
$intPage		= $objRequest->getParam('page', 1);
$intOffset		= ($intPage - 1) * $intLimit;
$intTotal		= 0;
$objProduct		= new Product();
if(isset($intCate) && isset($intSub)) {
	$strUrl		= LINK_PRODUCT . '?cate=' . $intCate . '&sub=' . $intSub;
	if($intTargetHexId) $strUrl .= '&targetid=' . $intTargetHexId;
	$arrResult	= $objProduct->getAll($intCate, $intSub, 1, $intOffset, $intLimit, $intTotal);
	$this->view->intTotal	= $intTotal;
	$this->view->intOffset	= $intOffset;
	$this->view->intLimit	= $intLimit;
	$this->view->strUrl		= $strUrl;
} elseif(isset($intCate) && !isset($intSub)) {
	$arrSub		= $objCommon->getCategory($intCate,9,1,0);
	if($arrSub) {
		$arrResult	= array();
		foreach($arrSub as $value) {
			$arrData		= $objProduct->getAll($intCate, $value['categoryid'], 1, 0, 6);
			$arrResult[]	= array('id' => $value['categoryid'],'name' => $value['name'], 'data' => $arrData);
		}
	}
} else {
	$strUrl		= LINK_PRODUCT . '?';
	if($intTargetHexId) $strUrl .= 'targetid=' . $intTargetHexId . '&';
	$arrResult	= $objProduct->getAll(0, 0, 2, $intOffset, $intLimit, $intTotal);
	$this->view->intTotal	= $intTotal;
	$this->view->intOffset	= $intOffset;
	$this->view->intLimit	= $intLimit;
	$this->view->strUrl		= $strUrl;
}
$this->view->arrBasketSta	= $objProduct->getBasketSta($AppUI->id, $intTargetId);
$this->view->intCate 		= $intCate;
$this->view->intSub			= $intSub;
$this->view->arrResult		= $arrResult;
?>